#pragma once

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include "index.hpp"

namespace Util
{
    // 读写文件
    class FIleUtile
    {
        bool Read(std::ifstream &f, std::string *fulltext)
        {
            std::string line;
            while (getline(f, line))
            {
                *fulltext += line;
            }

            return true;
        }
    };

    // 切割字符串
    class StringUtil
    {
    public:
        static bool Cutstring(const std::string &s, std::vector<std::string> *words)
        {
            // 字典
            const char *const DICT_PATH = "/root/tcp-server/source/http/boost/dict/jieba.dict.utf8";
            const char *const HMM_PATH = "/root/tcp-server/source/http/boost/dict/hmm_model.utf8";
            const char *const USER_DICT_PATH = "/root/tcp-server/source/http/boost/dict/user.dict.utf8";
            const char *const IDF_PATH = "/root/tcp-server/source/http/boost/dict/idf.utf8";
            const char *const STOP_WORD_PATH = "/root/tcp-server/source/http/boost/dict/stop_words.utf8";

            static cppjieba::Jieba jieba(DICT_PATH,
                                         HMM_PATH,
                                         USER_DICT_PATH,
                                         IDF_PATH,
                                         STOP_WORD_PATH);

            jieba.CutForSearch(s, *words);
            return true;
        }
    };

};